var qrcode = $("#qrcode").val();
var fName = $("#fName").val();
var fModel = $("#fModel").val();
var fBatchNo = $("#fBatchNo").val();
var fStocker = $("#fStocker").val();
var fPrintNum = $("#fPrintNum").val();
var fItemID = $("#fItemID").val();
var fStockID = $("#fStockID").val();
var fStockPlaceID = $("#fStockPlaceID").val();
$('#fNamess').text(fName);
$('#fModelss').text(fModel);
$('#fBatchNoss').text(fBatchNo);
if(fStocker!='null'){
	$('#fStockerss').text(fStocker);
}
$('#fPrintNumss').text(fPrintNum);
/*
 * @Description: 预加载
 * @param : 
 */
$(function (){
	$("#headinger").qrcode({
		width: 110,
		height: 110,
		correctLevel : 3,
		text: '[{"fItemID":"'+fItemID+'","fStockID":"'+fStockID+'","fBatchNo":"'+fBatchNo+'","fStockPlaceID":"'+fStockPlaceID+'"}]'
	});
	setTimeout(function(){
		print();
	}, 500);
});

/*
 * @Description: 打印
 * @param :
 */
function print() {
	var canvas=document.getElementsByTagName("canvas")[0];
	var dataURL = canvas.toDataURL("image/png");
	var img = '<img src="'+dataURL+'"></img>';
	$("#headinger").html(img);
	$(".row").print({
		deferred: $.Deferred().done(function() {
			printnum();
			setTimeout(function(){
				window.close(); 
			}, 1000);
		})//打印完后自动关闭打印页面
	});
}
//打印次数接口
function printnum(){
	$.ajax({//发料仓库
		url : pathUrl("icinventory/setPrintNum.action"),
		dataType : "JSON",
		type : 'POST',
		data:{
			"fItemID":fItemID,
			"fStockID":fStockID,
			"fStockPlaceID":fStockPlaceID,
			"fBatchNo":fBatchNo,
		},
		success : function(data) {
			console.log('shdkhs');
		},
		error : function(request) {
			console.log('xxxx');
		}
	});
}